package com.cskaoyan.interceptor;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.lang.Object;

/**
 * @program: spring-boot-template
 * @description: 用户登录拦截
 * @author: fish-team
 * @create: 2021-11-28 21:25
 **/
@Component
public class UserHandlerInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {


//        HttpSession session = request.getSession();
//
//        if (session == null || session.getAttribute("token") == null) {
//            // 如果session不存在，或者登录令牌不存在，表面未登录，拦截请求
//            response.getWriter().println("请先登录");
//            return false;
//        }
        return true;

    }

}
